home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 8614 / 8614.xpi / modules / ClientInfo.jsm
Text File  |  2010-02-10  |  1KB  |  44 lines

  1. // DO NOT import this into the global namespace, but instead
  2. // import it into your own namespace wrapper
  3.  
  4. var EXPORTED_SYMBOLS = ["CLIENT_INFO"];
  5.  
  6. Components.utils.import("resource://glydo/utils/prototype_xul_1_6_0_3_modified.jsm");
  7. Components.utils.import("resource://glydo/utils/io.jsm");
  8. Components.utils.import("resource://glydo/utils/Utils.jsm");
  9.  
  10. const MY_APP_ID = "{363c6421-6d58-11dd-876c-001f3a388e21}";
  11.  
  12. var CLIENT_INFO = ({
  13.     init: function(appId) {
  14.         this.appId = appId;
  15.         this.version = Utils.extensionVersion(appId);
  16.         this.initClientID();
  17.     },
  18.     
  19.     initClientID: function() {
  20.         var file = DirIO.get("ProfD");
  21.         file.append("glydo");
  22.         DirIO.create(file);
  23.         file.append("clientid");
  24.         if (FileIO.create(file)) {
  25.             
  26.             this.clientId = Utils.uuid1();
  27.             if (!FileIO.write(file,this.clientId)) {
  28.                 throw "Can't store client ID into file";
  29.             }
  30.         } else {
  31.             
  32.             // File already exists, load id
  33.             this.clientId = FileIO.read(file);
  34.             if (this.clientId === false) {
  35.                 throw "Can't read client ID from file";
  36.             }
  37.         }
  38.         
  39.     },
  40.     
  41. });
  42.  
  43. CLIENT_INFO.init(MY_APP_ID);
  44.